from datetime import datetime, timedelta
from dataProcess import prepareGWACSVOMData

def generate_date_strings(start_date, end_date):
    start = datetime.strptime(start_date, "%Y-%m-%d")
    end = datetime.strptime(end_date, "%Y-%m-%d")
    
    date_list = []
    current = start
    while current <= end:
        date_list.append(current.strftime("%Y-%m-%d"))
        current += timedelta(days=1)
    
    return date_list

def batchQueryAndProcess():
    
    start_date, end_date = "2024-10-01", "2025-02-27"
    dates = generate_date_strings(start_date, end_date)
    # print(dates)
    
    for tdateStr in dates:
        try:
            prepareGWACSVOMData(tdateStr)
            # break
        except Exception as e:
            print("Error processing data for {}: {}".format(tdateStr, str(e)))

if __name__ == "__main__":
    batchQueryAndProcess()